package com.yang.core.service;

import com.yang.core.dao.AddressRepository;
import com.yang.core.dao.TitleRepository;
import com.yang.core.model.Address;
import com.yang.core.model.Title;
import com.yang.service.api.AddrService;
import com.yang.service.api.TitleService;
import com.yang.service.model.dto.post.AddrPostDTO;
import com.yang.service.model.dto.put.AddrPutDTO;
import com.yang.service.model.vo.AddrVo;
import com.zhy.base.exception.model.ExceptionEnum;
import com.zhy.base.exception.utils.AssertHelper;
import com.zhy.base.tools.beans.BeanMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.web.bind.annotation.*;

import javax.transaction.Transactional;
import javax.validation.Valid;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by xin7k
 * Date: 2019/12/2
 */
@Slf4j
@RestController
@RequestMapping("title")
@Api(tags = "头条操作API", description = "title")
public class TitleServiceImpl implements TitleService {
    @Autowired
    private BeanMapper beanMapper;
    @Autowired
    private TitleRepository titleRepository;

    @ApiOperation("获取所有的标题")
    @GetMapping("")
    @Override
    public List<String> getTitle() {
        List<String> re = new ArrayList<>();
        List<Title> all = titleRepository.findAll();
        for(int i =0; i < all.size(); i++){
            re.add(all.get(i).getTitle());
        }
        return re;
    }
}
